package com.tencent.wxcloudrun.service;

import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;

@Service
public class SmsService {

    private final Map<String, String> verificationCodes = new HashMap<>();

    // 发送验证码
    public void sendCode(String phone) {
        String code = String.valueOf((int) (Math.random() * 900000 + 100000));
        verificationCodes.put(phone, code);
        System.out.println("【短信验证码】" + phone + " - " + code);
    }

    // 验证验证码
    public boolean verifyCode(String phone, String code) {
        return verificationCodes.containsKey(phone) && verificationCodes.get(phone).equals(code);
    }
}
